﻿using System;
using System.Collections.Specialized;
using CARMSBusiness.InterFace;

namespace CARMS.Admin
{
    [Function("Admin.Configuration")]
    public partial class Configuration : PageBase
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtDateFormat.Text = ApplicationConfiguration.DateFormat;
                txtAdminEmail.Text = ApplicationConfiguration.AdminEmail;
                txtDefaultPassword.Text = ApplicationConfiguration.DefaultPassword;
            }
        }
        protected void btnSaveConfig_Click(object sender, EventArgs e)
        {
            SaveConfigrations();
        }
        protected void SaveConfigrations()
        {
            ApplicationConfiguration.SaveConfiguration(ApplicationConfiguration.AdminEmailID, txtAdminEmail.Text.Trim());
            ApplicationConfiguration.SaveConfiguration(ApplicationConfiguration.DataFormatKeyID, txtDateFormat.Text.Trim());
            ApplicationConfiguration.SaveConfiguration(ApplicationConfiguration.DefaultPasswordID, txtDefaultPassword.Text.Trim());
            base.Alert("Successfully saved!");
        }
    }
}
